//package org.example.dingtalkintegrationservice.aspect;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.slf4j.MDC;
//import org.springframework.stereotype.Component;
//import javax.servlet.http.HttpServletRequest;
//import java.util.UUID;
///**
// * @author pc
// */
//@Aspect
//@Component
//public class RequestAspect {
//    private static final String REQUEST_ID = "requestId";
//
//    @Around("@annotation(org.springframework.web.bind.annotation.RequestMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
//    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
//
////        HttpServletRequest request = (HttpServletRequest) joinPoint.getArgs()[0];
////        String requestId = request.getHeader(REQUEST_ID);
////        if (requestId == null || requestId.isEmpty()) {
//            String requestId = UUID.randomUUID().toString();
////        }
////        request.setAttribute(REQUEST_ID,requestId);
//        // 将 requestId 添加到 Mapped Diagnostic Context (MDC) 中
//        MDC.put(REQUEST_ID, requestId);
//        try{return joinPoint.proceed();}
//        finally {
//            // 请求处理完毕后，从 MDC 中移除 requestId
//            MDC.remove(REQUEST_ID);
//        }
//    }
//}